<template>
  <div class="container">
    <div class="fixedContainer">
      <!-- 主页 -->
      <div class="homeIcon" @click="toWhere('/')">
        <van-icon size="30px" class="homeIcon1" name="wap-home-o" />
      </div>
      <!-- 标题 -->
      <div class="title">{{ title }}</div>
      <!-- 搜索和购物车 -->
      <div class="searchOrCart">
        <div class="search" @click="toWhere('/search')">
          <van-icon size="30px" name="search" />
        </div>
        <div class="cart" @click="toWhere('/')">
          <van-icon size="30px" name="shopping-cart-o" />
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'SearchIcon'
})
</script>
<script lang="ts" setup>
import { useRouter } from 'vue-router'
const router = useRouter()
defineProps({
  title: {
    type: String,
    default: ''
  }
})
// 跳转到指定页
const toWhere = (address: string) => {
  router.push(address)
}
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 50px;
  .fixedContainer {
    width: 100%;
    height: 50px;
    position: fixed !important;
    left: 0;
    top: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px 0 12px;
    box-sizing: border-box;
    background-color: #fff;
    .title {
      flex: 1;
      text-align: center;
      line-height: 50px;
      font-size: 18px;
      color: #000;
      margin-left: 40px;
    }
    .searchOrCart {
      width: 70px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .search,
      .cart {
        margin-top: 4px;
      }
    }
  }
}
</style>
